// var focusIndex = 0 // 我不知道
// var realIndex = 2 // 我不知道
var swiper = new Swiper('.swiper-container-house', {
  loop: true, // 循环模式选项
  effect: 'coverflow',
  slidesPerView: 2,
  observer: true,
  observeParents: true,
  centeredSlides: true,
  coverflowEffect: {
    rotate: -14,
    stretch: -100,
    depth: 280,
    modifier: 1,
    slideShadows: false
  },
  on: {
    transitionEnd: function () {
      let index = this.realIndex
      $(".img-item").removeClass('active').eq(index).addClass('active')
      if (typeof (a) === 'undefined') {
        fetch1(1, function () {
          fetch2(1)
          fetch3(1)
          fetch5(1, function () {
            fetch4(1)
          })
        })
        setTimeout(()=>{
          window.b = 1;
          fetch6(1, function () {})
          fetch7(1, function () {})
          fetch8(1, function () {})
        },7000)
        window.a = 1

      }
    },
    slideChangeTransitionEnd: function () {
      // if (swiper && focusIndex !== realIndex) {
      //   focusIndex = realIndex;
      //   swiper.slideToLoop(realIndex, 0);
      // }

    },
    resize: function(){
      this.update(); //窗口变化时，更新Swiper的一些属性，如宽高等
    }
  }
});

var swiper1 = new Swiper('.swiper-container-person', {
  loop: true, // 循环模式选项
  effect: 'coverflow',
  initialSlide: 0,
  slidesPerView: 2,
  centeredSlides: true,
  observer: true,
  observeParents: true,
  runCallbacksOnInit: false,
  coverflowEffect: {
    rotate: -14,
    stretch: -100,
    depth: 280,
    modifier: 1,
    slideShadows: false
  },
  init: false,
  on: {
    slideChangeTransitionEnd: function () {
      let index = this.realIndex
      $(".img-item1").removeClass('active').eq(index).addClass('active')
    },
    transitionEnd: function () {
      let index = this.realIndex
      $(".img-item1").removeClass('active').eq(index).addClass('active')
    },
    resize: function(){
      this.update(); //窗口变化时，更新Swiper的一些属性，如宽高等
    }
  }
});
$('#swiperWrapper1').hide()
setTimeout(() => {
  swiper.slideToLoop(0, 50, false);

}, 50);


setTimeout(() => {
  swiper1.init()
  setTimeout(() => {
    swiper1.slideToLoop(0, 50, false);
  }, 1050);
}, 1000);


this.timer2 = null;
window.addEventListener('resize', () => {
  this.timer2 && clearTimeout(this.timer2);
  this.timer2 = setTimeout(() => {
    this.swiper.update(true);
    // this.swiper1.update(true);
  }, 500)
})
// 切换房屋和人
$('.house2').click(function () {
  $('.house2').hide()
  $('.house1').show()
  $('.person2').hide()
  $('.person1').show()
  $('.person-box').hide()
  $('.house-box').show()
})
$('.person1').click(function () {
  $('.house2').show()
  $('.house1').hide()
  $('.person2').show()
  $('.person1').hide()
  $('.person-box').show()
  $('.house-box').hide()
  swiper1.slideToLoop(0, 50, false);
  setTimeout(() => {
    swiper1.slideToLoop(0)
    $(".img-item1").removeClass('active').eq(0).addClass('active')
  }, 10)

})

// 切换swiper
$('.img-item').click(function () {
  let index = $(this).index()
  swiper.slideToLoop(index)
  $(".img-item").removeClass('active').eq(index).addClass('active')
})
$('.img-item1').click(function () {
  let index = $(this).index()
  swiper1.slideToLoop(index)
  $(".img-item1").removeClass('active').eq(index).addClass('active')
})

// 显示说明
$(".house-box .tip-trigger").click(function () {
  $(".house-box .tip-container").show()
})
$(".house-box .close-tip").click(function () {
  $(".house-box .tip-container").hide()
})
$(".person-box .tip-trigger").click(function () {
  $(".person-box .tip-container").show()
})
$(".person-box .close-tip").click(function () {
  $(".person-box .tip-container").hide()
})

// 关闭弹框
$('.close-popup').click(function () {
  $('.popup-bg').hide()
  $('.popup').hide()
  $('.popup1').hide()
  $('.popup2').hide()
  $('.popup4').hide()
  $('.popup5').hide()
  $('.popup5-1').hide()
  $('.popup6').hide()
  $('.popup7').hide()
})

/*
var myLately7Day = echarts.init(document.getElementById('lately7Day'))
var chartDom7Day = {
  tooltip: {
    trigger: 'axis'
  },
  legend: {
    data: ['小白 | 13291488223 | 411123199303150056', '小黑 | 13291488223 | 411123199303150056'],
    orient: 'vertical',
    right: '40',
    textStyle: {
      color: "#fff"
    }
  },
  grid: {
    left: '3%',
    right: '4%',
    bottom: '3%',
    containLabel: true
  },
  xAxis: {
    type: 'category',
    boundaryGap: false,
    splitLine: {
      show: false
    },
    axisLine: {
      color: '#43ECFF',
      show: true,
      lineStyle: {
        color: '#43ECFF',//刻度线的颜色
      }
    },
    data: ['0点', '1点', '2点', '3点', '4点', '5点', '6点', '7点', '8点', '9点', '10点', '11点', '12点', '13点', '14点', '15点', '16点', '17点', '18点', '19点', '20点', '21点', '22点', '23点', '24点',]
  },
  yAxis: {
    type: 'value',
    splitLine: {
      show: false
    },
    axisLine: {
      color: '#43ECFF',
      show: true,
      lineStyle: {
        color: '#43ECFF',//刻度线的颜色
      }
    },
  },
  series: [
    {
      name: '小白 | 13291488223 | 411123199303150056',
      type: 'line',
      stack: '总量',
      itemStyle: {
        color: '#1071B0'
      },
      data: [120, 132, 101, 134, 90, 230, 210]
    },
    {
      name: '小黑 | 13291488223 | 411123199303150056',
      type: 'line',
      stack: '总量',
      itemStyle: {
        color: '#1EBFA6'
      },
      data: [220, 182, 191, 234, 290, 330, 310]
    }
  ]
}

myLately7Day.setOption(chartDom7Day);
*/
